<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="/css/reset.css">
    <link rel="stylesheet" type="text/css" href="/css/iconfont.css">
    <link rel="stylesheet" type="text/css" href="/css/common.css">
    <title>登录</title>
  </head>
  <body>
    <div class="header_fixed">
        <div class="h_btn_left" onclick="javascript:history.go(-1)">
          返回
        </div>
        <div class="top-title">
          骚年，请先登录！
        </div>
        <div class="h_btn_right" onclick="javascript:location.href='register'">
          注册
        </div>
    </div>
    <div class="cs_content">
      <div class="login_box">
        <input type="text" id="username" name="" value="" placeholder="账户">
        <input type="password" id="password" name="" value="" placeholder="密码">
        <button type="button" name="button" onclick="login()">登录</button>
      </div>

    </div>
    <script src="js/zepto.js" charset="utf-8"></script>
    <script type="text/javascript">
      function login() {
        var username = document.getElementById('username').value;
        var password =  document.getElementById('password').value;
        $.ajax({
          type:'post',
          url:'/login',
          data:{
            name:username,
            password:password,
          },
          dataType:'json',
          success:function(ret){

            if(ret.ret_code ==0){
              alert(ret.ret_msg);
              location.href="/";

            }else{
                alert(ret.ret_msg);
            }
          },
          error:function(err){
            // console.log(err);
          }
        })
      }

    </script>
  </body>
</html>
